package cz.najman.emdroid.helper;

import java.util.HashMap;
import java.util.Map;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import cz.najman.emdroid.listener.OnDataUpdatedListener;
import cz.najman.emdroid.service.ForwardingResultReceiver;
import cz.najman.emdroid.utils.WhereClauseBuilder;

public abstract class AbstractHelper {

	protected Map<String, OnDataUpdatedListener> mListeners;
	protected final Context mContext;
	protected final ContentResolver mContentResolver;
	protected final ForwardingResultReceiver mResultReceiver;
	protected final WhereClauseBuilder mWCB;
	
	public AbstractHelper(Context context, ForwardingResultReceiver receiver) {
		mListeners = new HashMap<String, OnDataUpdatedListener>();
		mContext = context;
		mContentResolver = context.getContentResolver();
		mResultReceiver = receiver;
		mWCB = WhereClauseBuilder.getInstance();
	}
		
	public boolean registerListener(String tag, OnDataUpdatedListener listener){
		return mResultReceiver.registerListener(tag, listener);
	}
	
	public boolean unregisterListener(String tag){
		return mResultReceiver.unregisterListener(tag);
	}
	
	protected abstract Intent getIntentWithExtra(Uri uri, int method, String[] parameterTypes, String[] parameterValues, ContentValues values);
	
}
